package com.example.doubao_ai_demo.controller;

import com.example.doubao_ai_demo.request.SearchQueryRequest;
import com.example.doubao_ai_demo.service.DouBaoAiService;
import com.volcengine.ark.runtime.model.completion.chat.ChatCompletionChoice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ai")
public class DouBaoAiController {

    @Autowired
    private DouBaoAiService douBaoAiService;

    @PostMapping("/search")
    public List<ChatCompletionChoice> getSearchContent(@RequestParam("prompt") String prompt,
                                                       @RequestParam("input") String input) {
        return douBaoAiService.getSearchContent(prompt, input);
    }

    @PostMapping("/search1")
    public List<ChatCompletionChoice> getSearchContent1(@RequestBody SearchQueryRequest request) {
        return douBaoAiService.getSearchContent(request.getPrompt(), request.getInput());
    }
}
